defer = xend.netif_dev_create(vm.dom, vif, val, recreate=vm.recreate)
def fn(id):
dev = xend.netif_dev(vm.dom, vif)
- dev.vifctl('up')
+ dev.vifctl('up', vmname=vm.name)
vm.add_device('vif', dev)
print 'vm_dev_vif> created', dev
return id
"""
return ':'.join(map(lambda x: "%x" % x, self.mac))
- def vifctl_params(self):
- from xen.xend import XendDomain
- xd = XendDomain.instance()
+ def vifctl_params(self, vmname=None):
dom = self.controller.dom
- dominfo = xd.domain_get(dom)
- name = (dominfo and dominfo.name) or ('DOM%d' % dom)
+ name = vmname or ('DOM%d' % dom)
return { 'domain': name,
'vif' : self.get_vifname(),
'mac' : self.get_mac(),
'script': self.script,
'ipaddr': self.ipaddr, }
- def vifctl(self, op):
+ def vifctl(self, op, vmname=None):
"""Bring the device up or down.
"""
- Vifctl.vifctl(op, **self.vifctl_params())
+ Vifctl.vifctl(op, **self.vifctl_params(vmname=vmname))
def destroy(self):
"""Destroy the device's resources and disconnect from the back-end
def cb_destroy(val):
self.controller.send_be_destroy(self.vif)
self.vifctl('down')
- #d = self.controller.factory.addDeferred()
d = defer.Deferred()
d.addCallback(cb_destroy)
self.controller.send_be_disconnect(self.vif, response=d)
def reattach_devices(self):
"""Reattach all devices when the back-end control domain has changed.
"""
- #d = self.factory.addDeferred()
self.send_be_create(vif)
self.attach_fe_devices()